<template>
  <div class="c-ph24 c-p c-pt90">
    <div class="tab-hd-seat">
      <my-small-tabbar :tabList="tabs" :tabIndex="tabIndex" @changeTab="changeTab"></my-small-tabbar>
    </div>
    <!-- 大转盘 -->
    <template v-if="tabIndex==1">
      <div class="c-flex-row c-pv30 c-bd-b1" v-for="(item,index) in recordList" :key="index" @click.stop="handleClickDetail(item.url)">
        <div class="c-ww140 c-hh140 c-text-hidden c-br10">
          <img class="c-w100 c-h imgCloseBig c-br10" :src="$addXossFilter(item.awardImgUrl)" alt="">
        </div>
        <div class="c-flex-column c-justify-sb c-flex-grow1 c-w0 c-pl20 c-pv10">
          <div class="c-text-ellipsis1 c-fs26 c-fw500">{{item.awardName}}</div>
          <div class="c-text-ellipsis1 c-fs20 c-fc-gray">中奖时间:{{item.createdAt}}</div>
        </div>
        <template v-show="item.awardType == 3">
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType != 2&&((item.operateType == 4 && item.mallInfo.getAwardStatus == 0) || item.operateType == 3)"
            @click.stop="handleClickRecord(item)">领取奖品</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType != 2&&item.operateType == 4 && item.mallInfo.getAwardStatus == 1"
            @click.stop="handleClickDetail(item.url)">待发货</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType != 2&&item.operateType == 4 && item.mallInfo.getAwardStatus == 2 && item.deliverType != 3"
            @click.stop="handleClickDetail(item.logisticsUrl)">快递详情</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType != 2&&item.operateType == 4 && item.mallInfo.getAwardStatus == -1">库存不足</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType != 2&&item.operateType == 4 && item.mallInfo.getAwardStatus == -2">商品下架</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType != 2&&(item.operateType == 1 || item.operateType == 2)" @click.stop="handleClickRecord(item)">
            快递详情</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType == 2 && item.mallInfo.getAwardStatus == 1">
            待自提</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType == 2 && item.mallInfo.getAwardStatus == 2" @click.stop="clickConfirmReceipt(item.mallInfo.mallOrderId)">
            确认收货</div>
          <div class="c-ww120 c-hh36 c-br18 prize-btn c-fs22 c-flex-column c-justify-center c-aligni-center" v-if="item.deliverType == 2 && item.mallInfo.getAwardStatus == 3">
            已自提</div>
        </template>
      </div>
    </template>
    <!-- 抽奖 -->
    <template v-else-if="tabIndex==2">
      <ul class="tab-bd">
        <li v-for="(item,index) in recordList" :key="index" @click="handlePrize(item)">
          <div class="pic c-br10 c-flex-shrink0 c-flex-row c-justify-center c-aligni-center">
            <!-- 实体 -->
            <img v-if="item.prizeType==2" :src="$addXossFilter(item.prodAvatar)" class="c-maxw c-maxh" />
            <!-- 积分 -->
            <img v-else-if="item.prizeType==3" src="@/assets/i/wap/live/choujiang/jifen.png" class="c-maxw c-maxh" />
            <!-- 红包 -->
            <img v-else-if="item.prizeType==4" src="@/assets/i/wap/live/choujiang/award_hb.png" class="c-maxw c-maxh" />
            <!-- 虚拟（商品和优惠卷） -->
            <template v-else>
              <div v-if="item.type" class="c-p c-mlr-auto prize-coupon" :class="['type-'+item.type]">
                <div v-if="item.type==1" class="c-pa c-translate-xy-50 c-p-tl50 c-p-tp50 c-fc-white c-fs28 c-ws-n">兑换劵</div>
                <div v-else-if="item.type==4" class="c-pa c-translate-xy-50 c-p-tl50 c-p-tp50 c-fc-white c-fs28 c-ws-n">抵价券</div>
                <template v-else>
                  <div v-if="item.type==5" class="c-fs26 c-textAlign-c c-fw500 c-fc-white c-hh64 c-lh64">{{Number(item.price)}}折</div>
                  <div v-else class="c-fs20 c-textAlign-c c-fw500 c-fc-white c-hh64 c-lh64">{{'￥' | iosPriceFilter}}<span class="c-fs28">{{Number(item.price)}}</span></div>
                  <div class="c-fs20 c-textAlign-c c-fc-white c-hh40 c-lh40">{{Number(item.amount) > 0 ? '满'+Number(item.amount)+'可用' : '无门槛'}}</div>
                </template>
              </div>
              <template v-else>
                <img v-if="item.prodType==1" class="c-maxw c-maxh" :src="$addXossFilter(item.prodAvatar,require('@/assets/i/wap/course/vip.png'))" />
                <img v-else-if="item.prodType==23" class="c-maxw c-maxh" :src="$addXossFilter(item.prodAvatar,require('@/assets/i/wap/course/svip.png'))" />
                <img v-else :src="$addXossFilter(item.prodAvatar)" class="c-maxw c-maxh" />
              </template>
            </template>
          </div>
          <p class="c-fs24 c-fw400 c-lh34">{{item.prodName}}</p>
          <p class="c-fs20 c-fc-gray c-lh28 c-mt10">中奖时间：{{item.prizeAt}}</p>
          <!-- 实体商品的时候 -->
          <template v-if="item.prizeType==2">
            <p v-if="item.isReceived==1" class="c-bg-reword c-br32 c-ww104 c-hh36 c-lh36 c-textAlign-c c-fc-white c-fs18 c-mt20 c-block">已领取</p>
            <p v-else-if="item.isReceived==2" class="c-bg-e6 c-br32 c-ww104 c-hh36 c-lh36 c-textAlign-c c-fc-xblack c-fs18 c-mt20 c-block">已过期</p>
            <p v-else class="c-bg-reword c-br32 c-ww104 c-hh36 c-lh36 c-textAlign-c c-fc-white c-fs18 c-mt20">立即领取</p>
          </template>
        </li>
      </ul>
    </template>
    <template v-else-if="tabIndex==3">
      <ul class="tab-bd">
        <li v-for="(item,index) in recordList" :key="index" @click="handlePrize(item)">
          <div class="pic c-br10 c-flex-shrink0 c-flex-row c-justify-center c-aligni-center">
            <!-- 实体 -->
            <img v-if="item.wealType==2" :src="$addXossFilter(item.prodAvatar)" class="c-maxw c-maxh" />
            <!-- 积分 -->
            <img v-else-if="item.wealType==3" src="@/assets/i/wap/live/choujiang/jifen.png" class="c-maxw c-maxh" />
            <!-- 红包 -->
            <img v-else-if="item.wealType==4" src="@/assets/i/wap/live/choujiang/award_hb.png" class="c-maxw c-maxh" />
            <!-- 虚拟（商品和优惠卷） -->
            <template v-else>
              <div v-if="item.type" class="c-p c-mlr-auto prize-coupon" :class="['type-'+item.type]">
                <div v-if="item.type==1" class="c-pa c-translate-xy-50 c-p-tl50 c-p-tp50 c-fc-white c-fs28 c-ws-n">兑换卷</div>
                <div v-else-if="item.type==4" class="c-pa c-translate-xy-50 c-p-tl50 c-p-tp50 c-fc-white c-fs28 c-ws-n">抵价券</div>
                <template v-else>
                  <div v-if="item.type==5" class="c-fs26 c-textAlign-c c-fw500 c-fc-white c-hh64 c-lh64">{{Number(item.price)}}折</div>
                  <div v-else class="c-fs20 c-textAlign-c c-fw500 c-fc-white c-hh64 c-lh64">{{'￥' | iosPriceFilter}}<span class="c-fs28">{{Number(item.price)}}</span></div>
                  <div class="c-fs20 c-textAlign-c c-fc-white c-hh40 c-lh40">{{Number(item.amount) > 0 ? '满'+Number(item.amount)+'可用' : '无门槛'}}</div>
                </template>
              </div>
              <template v-else>
                <img v-if="item.prodType==1" class="c-maxw c-maxh" :src="$addXossFilter(item.prodAvatar,require('@/assets/i/wap/course/vip.png'))" />
                <img v-else-if="item.prodType==23" class="c-maxw c-maxh" :src="$addXossFilter(item.prodAvatar,require('@/assets/i/wap/course/svip.png'))" />
                <img v-else :src="$addXossFilter(item.prodAvatar)" class="c-maxw c-maxh" />
              </template>
            </template>
          </div>
          <p class="c-fs24 c-fw400 c-lh34">{{item.prodName}}</p>
          <p class="c-fs20 c-fc-gray c-lh28 c-mt10">领取时间：{{item.createAt}}</p>
        </li>
      </ul>
    </template>
    <loading-status-tem :dataStatus="dataStatus" noDataText="您暂时还没获取福利奖品哦"></loading-status-tem>
    <!-- 快递详情 -->
    <cj-popup v-model="showExpress" round>
      <div class="c-ww520 c-h c-p c-bg-white c-br20 ">
        <div class="c-hh64 c-bd-b1 c-flex-column c-justify-center c-aligni-center c-fs24 c-fc-xblack">快递详情</div>
        <div class="c-ph24 c-mv32 c-maxh360 c-contexty-scroll">
          <div class="c-text-hidden c-lh-20 c-mb20">
            <label class="fl c-fc-gray c-fs22">收货人：</label>
            <div class="c-fs22 c-fc-xblac c-textAlign-l c-text-hidden">{{expressInfo.realName}}</div>
          </div>
          <div class="c-text-hidden c-lh-20 c-mb20">
            <label class="fl c-fc-gray c-fs22">联系电话：</label>
            <div class="c-fs22 c-fc-xblac c-textAlign-l c-text-hidden">{{expressInfo.mobile}}</div>
          </div>
          <div class="c-text-hidden c-lh-20 c-mb20">
            <label class="fl c-fc-gray c-fs22">收货地址：</label>
            <div class="c-fs22 c-fc-xblac c-textAlign-l c-text-hidden">{{expressInfo.provinceName+expressInfo.cityName+expressInfo.areaName+expressInfo.address}}</div>
          </div>
          <div class="c-text-hidden c-lh-20 c-mb20">
            <label class="fl c-fc-gray c-fs22">快递名称：</label>
            <div class="c-fs22 c-fc-xblac c-textAlign-l c-text-hidden">{{expressInfo.courierName || '暂无快递信息'}}</div>
          </div>
          <div class="c-text-hidden c-lh-20">
            <label class="fl c-fc-gray c-fs22">快递单号：</label>
            <div class="c-fs22 c-fc-xblac c-textAlign-l c-text-hidden">{{expressInfo.trackingNumber || '暂无快递信息'}}</div>
          </div>
        </div>
        <div class="c-w100 c-pb48">
          <div class="express-btn c-ww220 c-hh60 c-br30 c-fs24 c-fc-white c-textAlign-c c-lh60 c-m-0auto" @click="handleClickCloseExpress">我知道了</div>
        </div>
      </div>
    </cj-popup>
    <!-- 地址 -->
    <open-modal :openModal="openModal" @closeModal="closeModal">
      <div class="c-bg-white c-br-tl20 c-br-tr20 c-pr24 c-pb30 c-pl24 c-maxh760">
        <template v-if="addressInfo !== null">
          <div class="c-flex-row c-aligni-center c-justify-center c-p c-bd-b1 c-hh64">
            <span class="c-fs24 c-fc-xblack">收货地址</span>
            <span class="c-fs24 iconfont c-pa c-p-r24 c-fc-gray" @click="handleClickModal">&#xe8fd;</span>
          </div>
          <div class="c-flex-row c-aligni-center c-hh80 c-bd-b1">
            <span class="c-ww150 c-fs24 c-fc-gray">收件人</span>
            <input type="text" :disabled="disabled" v-model="addressInfo.name" class="input-right c-fs28 c-flex-grow1 c-w0 c-fc-xblack" placeholder="收件人">
          </div>
          <div class="c-flex-row c-aligni-center c-hh80 c-bd-b1">
            <span class="c-ww150 c-fs24 c-fc-gray">联系电话</span>
            <input type="tel" :disabled="disabled" v-model="addressInfo.mobile" class="input-right c-fs28 c-flex-grow1 c-w0  c-fc-xblack" placeholder="联系电话">
          </div>
          <div class="c-flex-row c-aligni-center c-hh80 c-bd-b1">
            <span class="c-ww150 c-fs24 c-fc-gray">所在地区</span>
            <div class="c-flex-row c-flex-grow1 c-w0 c-fs28  c-fc-xblack picker-address">
              <x-address :themeColor="$getThemeColor()" value-text-align='left' title="" :disabled="disabled" v-model="addrValue" :list="addressData" raw-value placeholder="请选择地址" :show.sync="showAddress" class="c-flex-grow1"
                @on-hide='valuetrue' @on-shadow-change="onShadowChange"></x-address>
            </div>
          </div>
          <div class="c-flex-row c-aligni-center c-hh80 c-bd-b1">
            <span class="c-ww150 c-fs24 c-fc-gray">详细地址</span>
            <input type="text" :disabled="disabled" v-model="addressInfo.address" class="input-right c-fs28 c-flex-grow1 c-w0  c-fc-xblack" placeholder="街道、楼牌号等">
          </div>
          <div class="c-hh72 c-fs24 c-fc-white c-br36 c-lh72 c-textAlign-c c-mt48 havePriz-comit" @click="handleClickCommit">提交</div>
          <!-- 选择切换收货地址：只有商城商品才有 -->
          <div class="c-fs24 c-fc-gray c-flex-row c-justify-center c-aligni-center c-mt48" v-show="operateType == 4" @click="handleClickAddress">选择收货地址</div>
        </template>
        <template v-else>
          <div class="c-flex-row c-aligni-center c-justify-center c-p c-bd-b1 c-hh64">
            <span class="c-fs24 c-fc-xblack">收货地址</span>
            <span class="c-fs24 iconfont c-pa c-p-r24 c-fc-gray" @click="handleClickModal">&#xe8fd;</span>
          </div>
          <div class="c-hh320 c-pt120 c-flex-row c-justify-center c-fs24 c-fc-gray">暂无收货地址，请点击新建收货地址</div>
          <div class="c-hh72 c-fs24 c-br36 c-lh72 c-textAlign-c c-mt48 address-ship" @click="handleClickAddress">新建收货地址</div>
        </template>
      </div>
    </open-modal>
    <!-- 领奖收货地址 -->
    <live-delivery-address ref="liveDeliveryAddress" @getAwardByAddrSuccess="getAwardByAddrSuccess"></live-delivery-address>

  </div>
</template>

<script>
import { XAddress } from 'ckjrweb-mp-ui/src/components/index';
import { utilJs } from "@/utils/common.js";
import loadingStatusTem from "@/components/templates/common/loadingStatusTem.vue";
import openModal from "@/components/templates/common/openModal.vue";
import liveDeliveryAddress from "@/components/templates/live/liveDeliveryAddress.vue";
import MySmallTabbar from "@/components/templates/common/MySmallTabbar.vue";
import { goDetails } from "@/utils/goDetails.js";
import {mapState} from "vuex";
export default {
  name: "winningRecordAll",
  data() {
    return {
      page: 1,
      limit: 10,
      tdId: '',
      dataStatus: 'HAS_MORE_DATA',
      recordList: [],
      showExpress: false,
      submitFlage: true, //领取奖品，防止重复点击
      // 领取奖品地址
      openModal: false,
      pickAddressValue: [],
      pickAdress: '',
      addressInfo: {
        no: 1,
        name: "",
        mobile: "",
        provinceId: "",
        cityId: "",
        areaId: "",
        address: "",
      },
      addrValue: [],
      addressData: [],
      showAddress: false,
      itemTaId: '',
      disabled: false,
      operateType: 0,
      expressInfo: {
        realName: '', //收货人
        mobile: '', //手机
        address: '', //地址
        courierName: '', //快递公司
        trackingNumber: '', //快递单号
        provinceName: '', //省
        cityName: '', //市
        areaName: '', //区
      },
      shopInfo: [],
      turntableData: {},
      freeShipping: 0,
      mallOrderId: '',
      tabIndex:1, // 1大转盘 2是抽奖  3是福利   修改tabIndex 要注意下关联的修改
      tabs:[
        {index:1, title:"大转盘奖品"},
        {index:2, title:"抽奖奖品", activityType:1}, //activityType是福利抽奖跳转状态机制
        {index:3, title:"福利奖品", activityType:2}
      ]
    }
  },
  components: {
    loadingStatusTem,
    XAddress,
    openModal,
    liveDeliveryAddress,
    MySmallTabbar
  },
  computed: {
    ...mapState({
       livePrizeInfo:state => state.live.prizeInfo
    })
  },
  creadted() {
    utilJs.appShare(this);
  },
  beforeRouteEnter(to, from, next) {
    if (from.path.includes("/mall/shippingAddress/addressList")) {
      next((vm) => {
        vm.openModal = true;
      });
    } else {
      next((vm) => {
        vm.openModal = false;
      });
    }
  },
  beforeRouteLeave(to, form, next) {
    if (to.path.includes("/mall/shippingAddress/addressList")) {
      next((vm) => {
        vm.openModal = true;
      });
    } else {
      next((vm) => {
        vm.openModal = false;
      });
    }
  },
  activated() {
    setDocumentTitle("我的中奖记录");
    this.taId = this.$route.query.taId || '';
    if (!this.taId && !this.$route.query.totalReward) {
       this._totalReward = 1;
    } else {
      this._totalReward = this.$route.query.totalReward;
    }
    if (this.$route.query.activityType) {
      this.tabIndex = this.tabs.find((item) => {
        return item.index == this.$route.query.activityType
      }).index;
    }
    if (this.livePrizeInfo) {
      this.openModal = false;
    }
    if (this.operateType == 4) {
      if (localStorage.getItem("AddressInfo")) {
        this.addressInfo = JSON.parse(localStorage.getItem("AddressInfo"));
        setTimeout(() => {
          this.addrValue = [
            "" + this.addressInfo.provinceId,
            "" + this.addressInfo.cityId,
            "" + this.addressInfo.areaId
          ]
        }, 10)
        localStorage.removeItem('AddressInfo');
      }
    } else {
      this.addrValue = [];
      this.addressInfo = {
        no: 1,
        name: "",
        mobile: "",
        provinceId: "",
        cityId: "",
        areaId: "",
        address: "",
      };
    }

    // this.itemTaId = '';
    this.expressInfo = {
      realName: '', //收货人
      mobile: '', //手机
      address: '', //地址
      courierName: '', //快递公司
      trackingNumber: '', //快递单号
      provinceName: '', //省
      cityName: '', //市
      areaName: '', //区
    }
    // this.openModal = false;
    this.initData();
    this.submitFlage = true;
    this.wechatShare();
    window.addEventListener('scroll', this.windowScrollFunction);
  },
  deactivated() {
    this.openModal = false;
    this.dataStatus = 'NO_MORE_DATA';
    window.removeEventListener('scroll', this.windowScrollFunction);
  },
  mounted() {
    this.getAddressData();
  },
  methods: {
    orderHandle() {
      utilJs.postMethod(
        global.apiurl + "goodsOrders/orderHandle",
        {
          status: 3,
          goId: this.mallOrderId
        },
        res => {
          this.initData();
        }
      );
    },
    changeTab(index) {
      window.scrollTo(0, 0);
      this.tabIndex = index;
      this.recordList = [];
      this.page = 1;
      this.$nextTick(() => {
        this._getList(index);
      })
    },
    //确认收货
    clickConfirmReceipt(goId) {
      this.mallOrderId = goId;
      this.$cjConfirm({
        title: '提示',
        message: '确认收货?',
        onConfirm:() => {
          this.orderHandle();
        }
      })
    },
    initData() {
      this.page = 1;
      this.dataStatus = 'HAS_MORE_DATA';
      this.recordList = [];
      this._getList(this.tabIndex);
    },
    handleClickDetail(url) {
      if (url == '') {
        return
      }
      utilJs.locationHref(url);
    },
    _getList(index) {
      if (this.dataStatus == 'LOADING') {
        return;
      }
      this.dataStatus == 'LOADING';
      let url = "";
      switch (index) {
        case 1:
          url = `${global.apiurl}activity/turntable/getWxTurntableLogList?page=${this.page}&limit=${this.limit}&taId=${this.taId}&totalReward=${this._totalReward}`;
          break;
        case 2:
          url = `${global.apiurl}live/lottery/getMyAllPrizeList?page=${this.page}&limit=${this.limit}`;
          break;
        case 3:
          url = `${global.apiurl}live/liveWeal/myAllLiveWeals?page=${this.page}&limit=${this.limit}`;
          break;
        default:
          url = `${global.apiurl}activity/turntable/getWxTurntableLogList?page=${this.page}&limit=${this.limit}&taId=${this.taId}&totalReward=${this._totalReward}`;
          break;
      }
      utilJs.getMethod(url, (res) => {
        if (index != this.tabIndex) return;
        this.recordList = this.recordList.concat(res.data);
        if (res.data && (res.data.length < this.limit)) {
          this.dataStatus = this.page == 1 && res.data.length == 0 ? 'NO_DATA' : 'NO_MORE_DATA';
        } else {
          this.dataStatus = 'HAS_MORE_DATA';
          this.page++;
        }
      }, () => {
          this.dataStatus = 'DATA_ERROR';
        }
      );
    },

    handlePrize(item) {
      if (item.isReceived == 2) {
        //过期的产品不跳转
        return;
      }
      let goPath = '';
      let pathQuery = {};
      //不同互动 type类型都不一样(抽奖，福利)
      if (item.prizeType == 2 || item.wealType == 2) {
        //实体商品
        if (item.prodType == 12 || item.prodType == 13) {
          //商品和独立商城的产品
          if (item.mallOrderId) {
            //已经领取
            goPath = '/mall/mallOrder/orderDetail';
            pathQuery.goId = item.mallOrderId;
            this.$routerGo(this, 'push', {
              path: goPath,
              query: pathQuery
            });
          } else if ((item.freightMode == 0 && Number(item.postage)) || item.freightMode == 1 || item.isMallOfflineDeliver == 1) {
            this.getAwardByOrder(item);
          } else {
            this.getAwardByAddr(item);
          }
        }
      } else if (item.prizeType == 3 || item.wealType == 3) {
        //积分商品
        goPath = '/member/myIntegral/integralDetail';
        this.$routerGo(this, 'push', {
          path: goPath,
          query: pathQuery
        });
      } else if (item.prizeType == 4 || item.wealType == 4) {
        //抽奖和福利红包
        goPath = '/member/scholarship/scholarshipIndex';
        this.$routerGo(this, 'push', {
          path: goPath,
          query: pathQuery
        });
      } else {
        if (item.prodType == 92) {
          this.$routerGo(this, 'push', {
            path: '/member/myValueVoucher/myValueVoucher'
          });
        } else {
          goDetails(this, item.prodType, item.prodId, '', item.courseType);
        }
      }
    },
    getAwardByAddr(item) {
      let prizeId = item.prizeId;
      let prizeType = item.prizeType;
      let activityType = this.tabs[this.tabIndex - 1].activityType;
      this.$store.commit('live/setPrizeInfo', { prizeId: prizeId, activityType:activityType, prizeType: prizeType, rId: item.rId});
      this.$refs.liveDeliveryAddress.open();
    },
    getAwardByOrder(item) {
      this.$store.commit('live/setPrizeInfo', { prizeId: item.prizeId, activityType: this.tabs[this.tabIndex - 1].activityType, prizeType: item.prizeType, rId: item.rId, prodId:item.prodId});
      utilJs.getMethod(`${global.apiurl}goods/goodsDetail?mgId=${item.prodId}`,
          res => {
            let goods = res.goods;
            let shopInfo = [
              {
                mgId: goods.mgId,
                mcId: '',
                avatar: goods.avatar || '',
                pointsDeduct: 0,
                name: goods.name,
                price: 0,
                originalPrice: goods.originalPrice,
                quantity: 1,
                shopSpecInfo: '',
                gsiiId: '',
                postage: goods.postage,
                isMail: goods.isMail,
                isMallExpressDeliver: goods.isMallExpressDeliver,
                isMallOfflineDeliver: goods.isMallOfflineDeliver,
                stock: 1,
                salesStock: '',
                collageStock: '',
                freeShipping: goods.freeShipping,
                isFlashSales: false,
                isCollage: false,
                pId: '',
                noLimit: false,
                vipDiscount: 0,
                svipDiscount: 0,
                agentDiscount: 0,
                partnerDiscount: 0,
                branchDiscount: 0,
                limitType: -1,
                limitNumber: 0,
                purchasedNum: 0
              }
            ];
            if (goods.valuationMethod == 1 && goods.valuationMethod == 2 && goods.freightMode == 1) {
              shopInfo.valuationMethod = goods.valuationMethod;
            }
            sessionStorage.setItem('shopBuyInfo', JSON.stringify(shopInfo));
            this.$routerGo(this, "push", {
              path: `/mall/shopSettlement/shopSettlement?shopNo=${item.prodId}&talId=${item.prizeId}`
            });
          }
        );
    },
    //领取奖品（填写收货地址）成功
    getAwardByAddrSuccess() {
      this.recordList = [];
      this.page = 1;
      this._getList(this.tabIndex)
    },
    getAddressData() {
      let _this = this;
      utilJs.getMethod(`${global.apiurl}common/getAreaListForAgent`, res => {
        _this.addressData = res.data;
      }, failRes => {
      });
    },
    closeModal() {
      this.addrValue = [];
      this.addressInfo = {
        no: 1,
        name: "",
        mobile: "",
        provinceId: "",
        cityId: "",
        areaId: "",
        address: "",
      };
      this.openModal = false;
    },
    handleClickModal() {
      this.addrValue = [];
      this.addressInfo = {
        no: 1,
        name: "",
        mobile: "",
        provinceId: "",
        cityId: "",
        areaId: "",
        address: "",
      };
      this.openModal = false;
    },
    handleClickCloseExpress() {
      this.showExpress = false;
    },
    handleClickCommit() {
      let _this = this;
      let saveData;
      let apiurl;
      if (_this.operateType == 4) {
        saveData = {
          talId: _this.itemTaId,
          userAddressId: _this.addressInfo.addrId
        }
        apiurl = 'activity/turntable/submitWxMallOrder';
      } else {
        saveData = {
          talId: _this.itemTaId,
          realName: _this.addressInfo.name,
          mobile: _this.addressInfo.mobile,
          address: _this.addressInfo.address,
          provinceId: _this.addrValue.length > 0 ? _this.addrValue[0] : "",
          cityId: _this.addrValue.length > 1 ? _this.addrValue[1] : "",
          areaId: _this.addrValue.length > 2 ? _this.addrValue[2] : "",
        }
        apiurl = 'activity/turntable/setTurntableLogInfo';
      }
      if (!_this.checkAddressInfo()) {
        return
      }
      if (this.submitFlage) {
        this.submitFlage = false;
        utilJs.postMethod(global.apiurl + apiurl, saveData, res => {
          _this.$showCjToast({
            text: "提交成功",
            type: "success",
          }).then(() => {
            _this.handleClickModal();
            this.submitFlage = true;
            location.reload();
          });
        }, failRes => {
          this.submitFlage = true;
        })
      }
    },
    checkAddressInfo() {
      if (!this.addressInfo.name) {
        this.$showCjToast({
          text: "收货人姓名不能为空",
          type: "warn",
          time: 1000
        });
        return false;
      } else if (!utilJs.isPhoneNumber(this.addressInfo.mobile)) {
        this.$showCjToast({
          text: "请输入正确的手机号",
          type: "warn",
          time: 1000
        });
        return;
      } else if (this.addrValue.length <= 0) {
        this.$showCjToast({
          text: "收货人地址不能为空",
          type: "warn",
          time: 1000
        });
        return false;
      } else if (!this.addressInfo.address) {
        this.$showCjToast({
          text: "收货人详细地址不能为空",
          type: "warn",
          time: 1000
        });
        return false;
      }
      return true;
    },
    handleClickRecord(item) {
      if (item.packageStatus == 0) {
        if (item.operateType == 3 || item.operateType == 4) {
          this.disabled = false;
          this.itemTaId = item.talId;
          this.operateType = item.operateType;
          if (item.operateType == 4) {
            this.disabled = true;
            this.addressInfo = item.mallInfo.address;
            this.addrValue = item.mallInfo.address !== null ? [
              "" + item.mallInfo.address.provinceId,
              "" + item.mallInfo.address.cityId,
              "" + item.mallInfo.address.areaId
            ] : []
          }
          this.openModal = true;
        } else {
          this.expressInfo = item.otherInfo;
          this.showExpress = true;
        }
      } else {
        this.getShopInfo(item);
      }
    },
    getShopInfo(item) {
      utilJs.getMethod(
        global.apiurl + "goods/goodsDetail?mgId=" + item.prodId + "&talId=" + item.talId,
        res => {
          this.shopInfo = res.goods;
          this.turntableData = res.turntableData;
          this.freeShipping = res.freeShipping
          let shopInfo = [
            {
              mgId: this.shopInfo.mgId,
              mcId: "",
              avatar: this.shopInfo.avatar ? this.shopInfo.avatar : "",
              pointsDeduct: 0,
              name: this.shopInfo.name,
              price: this.turntableData.price,
              originalPrice: this.shopInfo.originalPrice,
              quantity: 1,
              shopSpecInfo: "",
              gsiiId: "",
              postage: this.shopInfo.postage,
              isMail: this.shopInfo.isMail,
              isMallExpressDeliver: this.shopInfo.isMallExpressDeliver,
              isMallOfflineDeliver: this.shopInfo.isMallOfflineDeliver,
              stock: 1,
              salesStock: "",
              collageStock: "",
              freeShipping: this.freeShipping,
              isFlashSales: false,
              isCollage: false,
              pId: "",
              noLimit: false,
              vipDiscount: 0,
              svipDiscount: 0,
              agentDiscount: 0,
              partnerDiscount: 0,
              branchDiscount: 0,
              isTurntable: true,
              limitType: -1,
              limitNumber: 0,
              purchasedNum: 0
            }
          ];
          sessionStorage.setItem("shopBuyInfo", JSON.stringify(shopInfo));
          let goPath = "/mall/shopSettlement/shopSettlement?shopNo=" + item.prodId + "&talId=" + item.talId + "&taId=" + item.taId;
          this.$routerGo(this, "push", {
            path: goPath
          });
        }
      );
    },
    handleClickAddress() {
      // 新增收货地址跳转
      this.$routerGo(this, "push", {
        path: "/mall/shippingAddress/addressList"
      })
    },
    windowScrollFunction() {
      utilJs.handleLoading(() => {
        if (this.dataStatus == 'HAS_MORE_DATA' && this.recordList.length > 0) {
          this._timer && clearTimeout(this._timer);
          this._timer = setTimeout(() => {
            this._getList(this.tabIndex);
          }, 250)
        }
      });
    },
    onShadowChange(index, item) {
      this.pickAddressValue = index;
      this.pickAdress = item;
    },
    valuetrue() {
      this.addrValue = this.pickAddressValue;
    },
    //分享
    wechatShare: function () {
      let title = '我的中奖记录';
      let shareImg = window.localStorage.getItem("shareLogo");
      let shareUrl = `${window.location.href.split("#")[0]}#${this.$route.path}?taId=${this.taId}&totalReward=${this._totalReward}&refereeId=${localStorage.getItem("userId")}`;
      let shareDesc = '点击查看详情';
      utilJs.wechatConfig(shareUrl, title, shareImg, shareDesc);
    },
    //手机端分享
    appShare: function () {
      let title = '我的中奖记录';
      let shareImg = window.localStorage.getItem("shareLogo");
      let shareUrl = `${window.location.href.split("#")[0]}#${this.$route.path}?taId=${this.taId}&totalReward=${this._totalReward}&refereeId=${localStorage.getItem("userId")}`;
      let shareDesc = '点击查看详情';
      utilJs.appShareTrue(title, shareImg, shareUrl, shareDesc);
    },
  }
}
</script>

<style scoped lang="scss">
.express-btn {
  background: #fd5709;
}
.prize-btn {
  border: 1px solid #fd5709;
  color: #fd5709;
}
/deep/ .modal {
  z-index: 99 !important;
}
.input-right {
  height: 100%;
  border: 0;
  background: none;
  outline: none;
}
.havePriz-comit {
  background: #fd5709;
}
.address-ship {
  color: #fd5709;
}
::-webkit-input-placeholder {
  /* WebKit browsers */
  font-size: 0.6rem;
}
:-moz-placeholder {
  /* Mozilla Firefox 4 to 18 */
  font-size: 0.6rem;
}
::-moz-placeholder {
  /* Mozilla Firefox 19+ */
  font-size: 0.6rem;
}
:-ms-input-placeholder {
  /* Internet Explorer 10+ */
  font-size: 0.6rem;
}

.tab-hd-seat{
  height:2rem;
  background: #fff;
  position: fixed;
  left:50%;
  top:1.3rem;
  width: 16rem;
  transform: translate(-50%,0);
  z-index: 10;
}


.tab-bd {
  li {
    list-style: none;
    padding: 0.5rem 0.5rem 0.5rem 5.875rem;
    position: relative;
    min-height: 4.2rem;
    background: #fff;
    margin: 0 0 0.5rem 0;
    .pic {
      width: 4.8rem;
      height: 3.2rem;
      border-radius: 0.2rem;
      padding: 0.25rem;
      position: absolute;
      left: 0.5rem;
      top: 0.5rem;
      background: #f5f7fa;
    }
  }
}
.prize-coupon {
  width: 2.7rem;
  height: 2.7rem;
  background-size: 100%;
  background-position: top center;
  background-repeat: no-repeat;
  background-image: url("../../../assets/i/wap/live/choujiang/coupon_3_bg.png");
  &.type-1 {
    background-image: url("../../../assets/i/wap/live/choujiang/coupon_1_bg.png");
  }
  &.type-4 {
    background-image: url("../../../assets/i/wap/live/choujiang/coupon_2_bg.png");
  }
}
</style>
